import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { CarbasicInformationVO, CarbasicInformationForm, CarbasicInformationQuery } from '@/api/zichanguanli/carbasicInformation/types';

/**
 * 查询汽车基础信息列表
 * @param query
 * @returns {*}
 */

export const listCarbasicInformation = (query?: CarbasicInformationQuery): AxiosPromise<CarbasicInformationVO[]> => {
  return request({
    url: '/zichanguanli/carbasicInformation/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询汽车出租情况
 * @param query
 * @returns {*}
 */

export const getCarRental = (query?: any): AxiosPromise<CarbasicInformationVO[]> => {
  return request({
    url: '/zichanguanli/carbasicInformation/rental',
    method: 'get',
    params: query
  });
};

/**
 * 查询汽车注册年份情况
 * @param query
 * @returns {*}
 */

export const getCarRegistrationYear = (query?: any): AxiosPromise<CarbasicInformationVO[]> => {
  return request({
    url: '/zichanguanli/carbasicInformation/registrationYear',
    method: 'get',
    params: query
  });
};

/**
 * 查询汽车品牌分布情况
 * @param query
 * @returns {*}
 */

export const getCarBrandDistribution = (query?: any): AxiosPromise<CarbasicInformationVO[]> => {
  return request({
    url: '/zichanguanli/carbasicInformation/brandDistribution',
    method: 'get',
    params: query
  });
};

/**
 * 查询汽车品牌分布情况
 * @param query
 * @returns {*}
 */

export const getCarLineBarChart = (query?: any): AxiosPromise<CarbasicInformationVO[]> => {
  return request({
    url: '/zichanguanli/carbasicInformation/carLineBarChart',
    method: 'get',
    params: query
  });
};

/**
 * 查询汽车基础信息详细
 * @param id
 */
export const getCarbasicInformation = (params: any) => {
  return request({
    url: '/zichanguanli/carbasicInformation/getInfo',
    method: 'get',
    params
  });
};

/**
 * 新增汽车基础信息
 * @param data
 */
export const addCarbasicInformation = (data: CarbasicInformationForm): AxiosPromise<string | number> => {
  return request({
    url: '/zichanguanli/carbasicInformation',
    method: 'post',
    data: data
  });
};

/**
 * 修改汽车基础信息
 * @param data
 */
export const updateCarbasicInformation = (data: CarbasicInformationForm) => {
  return request({
    url: '/zichanguanli/carbasicInformation',
    method: 'put',
    data: data
  });
};

/**
 * 删除汽车基础信息
 * @param id
 */
export const delCarbasicInformation = (id: string | number | Array<string | number>) => {
  return request({
    url: '/zichanguanli/carbasicInformation?ids=' + id,
    method: 'delete'
  });
};

/**
 * 新增汽车收租计划
 * @param id
 */
export const addCarRentalProgram = (data: any) => {
  return request({
    url: '/zichanguanli/carRentalProgram',
    method: 'post',
    data
  });
};

/**
 * 修改汽车收租计划
 * @param id
 */
export const updateCarRentalProgram = (data: any) => {
  return request({
    url: '/zichanguanli/carRentalProgram',
    method: 'put',
    data
  });
};

/**
 * 获取汽车收租计划
 * @param id
 */
export const getCarRentalProgram = (params: any) => {
  return request({
    url: '/zichanguanli/carRentalProgram/list',
    method: 'get',
    params
  });
};

/**
 * 删除汽车收租计划
 * @param id
 */
export const delCarRentalProgram = (ids: any) => {
  return request({
    url: `/zichanguanli/carRentalProgram/${ids}`,
    method: 'delete'
  });
};
